import 'package:flutter/material.dart';
import 'package:flutter_my_web/pages/tools/drop_draw_board/base/DropBean.dart';
import 'package:flutter_my_web/pages/tools/drop_draw_board/base/build_utils.dart';
import 'package:flutter_my_web/pages/tools/drop_draw_board/base/base_drop_widget.dart';
import 'package:flutter_my_web/widget/TextWidget.dart';

class DropBeanText extends DropBean {
  var text = "文本";
  DropBeanText(){
    type = DropType.text;
  }

  @override
  List<Widget> bulidPropertyPanel() {
    var _controllerAddListener = TextEditingController(text: text);
    _controllerAddListener.addListener(() {
      if (this.text != _controllerAddListener.text) {
        this.text = _controllerAddListener.text;
        // print("刷新：${text}");
        refreshWidget();
      }
    });
    return super.bulidPropertyPanel()
      ..add(Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          SizedBox(height: 10,),
          Row(children: [
            SimpleText("文本"),
            Expanded(child: TextField(controller: _controllerAddListener)),
          ],),
        ],));
  }


  DropBeanText.fromJson(json) : super.fromJson(json){
    text = json['text'];
  }

  @override
  Map toJson() {
    return super.toJson()
      ..['text'] = text;
  }
}

class DropWidgetText extends BaseDropWidget<DropBeanText> {
  DropWidgetText(super.dropBean);

  @override
  Widget buildChildWidget() {
    return Center(child:Text(dropBean.text));
  }
}

